home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / cnet / formlett11.lha / FormLett.rexx < prev    next >
OS/2 REXX Batch file  |  1993-12-04  |  6KB  |  226 lines

  1.  
  2. /*
  3.  
  4. If you find yourself sending the same "Form-Letter" to users, again
  5. and again, this pfile is for you.
  6.  
  7. > Send to acct #, real-name, handle: 182
  8. >
  9. > Acct John Doe (#182 Johnny) has been sent Letter #D 5 times.
  10. > Acct John Doe (#182 Johnny) has been sent Letter #B 3 times.
  11. >
  12. > [A] Welcome mail
  13. > [B] Account about to expire
  14. > [C] U/Ling to wrong area
  15. > [D] FileNote short/vague
  16. > [E] FileNote missing
  17. > [F] Inappropriate msg post
  18. > [G] System problem
  19. > [H] Thanks for the suggestion
  20. >
  21. > Send which letter: C
  22. >
  23. > Acct #182 sent form-letter regarding "Acct about to expire".
  24.  
  25. Installation:
  26.    1) Copy FormLett.rexx TO Pfiles:
  27.    2) Copy *.form        TO SysText:
  28.  
  29.    3) Add the following file onto the END of your
  30.       BBSmenu "1; Maintenance menu" list:
  31.          FORmletter | {#0 pfiles:FormLett.rexx}
  32.  
  33.    4) Edit your "SysData:FormLett.cfg" file to reflect the
  34.       files you wish to send to users, subjects, and your menu display.
  35.  
  36.    5) Create the text-files that you've entered in "SysData:FormLett.cfg".
  37.       (Or use the *.form files that are provided in this archive.)
  38.       These *.form files are what gets sent to the users.
  39.  
  40.    6) Edit the variables below marked as "user-editable variables".
  41.  
  42. If you set the variable shown below called "tally" to "1", FormLett.rexx
  43. will create various Form_Lett.A files within each user's HOME directory.
  44. This will allow you to track how many times you've had to send a certain
  45. user the same reminder.
  46.  
  47. If you later wish to delete these tally-files, execute the DOS cmd:
  48. > Delete Mail:Users/#?/Form_Lett.?
  49.  
  50. If you set the variable shown below called "log" to "1", FormLett.rexx
  51. will write usage to the logs.  (You'll also have to have CONFIG/LOGS
  52. "ArexxSays" field turned on, as well as that user's log-flags.)
  53.  
  54. $VER: FormLett.rexx v1.1 Thu 02-Dec-93 23:40:23
  55.       First public release.
  56.  
  57. $VER: FormLett.rexx v1.0 Tue 29-Jun-93 07:16:45
  58.       Written and tested with CNet v2.94-beta
  59.       "[A] Custom" not yet supported.
  60.  
  61. Bill Beogelein
  62. Box 530441
  63. Livonia, MI 48153
  64. BBS 810-473-2020, Fido 1:2410/207
  65.  
  66. Ignore:
  67.    lz u CNet3:FormLett.LHA Pfiles:rexx/FormLett.#? a:zzzBBS SysText:nmail
  68.    lz u CNet3:FormLett.LHA SysText:#?.form SysData:FormLett.#? Gfiles:FAQ1/#?.form
  69.    Copy CNet3:FormLett.LHA UP:
  70.  
  71. Future plans and known bugs:
  72.    After CNet v3.0 is released, use 'getuser' instead of editpath variable.
  73.    Turning on "tally" wastes disk-space by creating many small files.
  74.    Allow FormLett to be callable from the edit using the current handle.
  75.    Loop in menu exit RETURN is hit.
  76.  
  77. */
  78.  
  79. /******* Top of user-editable variables *********/
  80. editpath = "R:p/"           /* Your CNet CONFIG/PATH "editor temp-files path" */
  81. cfgfile  = "SysData:FormLett.cfg"  /* Name/location of your FormLett.cfg file */
  82.  
  83.                   /* In each of the following cases... 0=NO, 1=YES   */
  84. tally    = 1      /* Track of how many times letters have been sent. */
  85. log      = 1      /* Write usage to logs.                            */
  86. /******* End of user-editable variables ***********/
  87.  
  88. options results
  89. call ToLog("Running pfile FormLett.rexx.")
  90. call LoadCfg()
  91. 'getuser' 23; port=RESULT
  92.  
  93. 'transmit' "n1        FormLett by Bill Beogelein"
  94. 'query' "n1Send to acct #, real-name, handle [none]: "; ans=RESULT
  95. if(ans="" | ans<1) then abort()
  96. 'FindAccount' ans
  97. acct=RESULT
  98.  
  99. 'loadScratch' acct
  100. if(RESULT==1) then
  101. do
  102.    'getScratch'  1; handle   = RESULT
  103.    'getScratch'  3; realname = RESULT
  104.    'getScratch' 39; home     = RESULT
  105.    'saveScratch' acct*(-1)
  106. end
  107. else
  108.    exit     /* CNet will tell user, "acct not found" */
  109.  
  110. if(tally) then call ShowCount()
  111.  
  112. do i=1 to max
  113.    'transmit' "[" || d2c(i+64) || "]" a.i.2
  114. end
  115.  
  116. 'sendString' "n1Send which letter to" realname "(#" || acct handle || ") [none]: "; 'getchar'; alpha=RESULT; 'transmit' alpha
  117. letter=c2d(alpha)-64
  118. if(letter<1 | letter>max) then abort()
  119.  
  120. defSubj  = a.letter.1
  121. 'query' "n1Subject [" || defSubj || "]: "; subj=RESULT
  122. if(subj="") then subj=defSubj
  123.  
  124. 'transmit' ""
  125. fname = a.letter.3
  126.  
  127. if(~exists(fname)) then
  128. do
  129.    'transmit' "*** Can't find filename" fname
  130.    exit
  131. end
  132.  
  133. 'SetMailSubj' subj
  134. tmpbuf = editpath || "_edbuff" || port
  135. cmd = "Copy" fname "to" tmpbuf
  136. 'transmit' cmd; address command cmd
  137.  
  138. 'WriteMail' acct
  139. ok=RESULT
  140. if(ok='1') then
  141. do
  142.    'transmit' "Sent" fname "to acct #" || acct
  143.    if(tally) then call IncCount(alpha)
  144.    call ToLog("FormLett.rexx sent" fname "to acct #" || acct)
  145. end
  146. else
  147.    'transmit' "*** Can't send" fname "TO acct #" || acct
  148.  
  149. 'transmit' "Done."
  150. exit
  151.  
  152. Abort:
  153.    'transmit' "n1*** FormLett.rexx aborted"
  154. exit
  155.  
  156. ShowCount:               /* Open Mail:Users/#/Form_Lett.A .B .C */
  157.    'transmit' ""
  158.    do which=65 to 65+26
  159.       countFile = "Mail:Users/" || home || "/Form_Lett." || d2c(which)
  160.       if(open(fp9, countFile, 'READ')) then
  161.       do
  162.          SentCount=readLN(fp9)
  163.          call close(fp9)
  164.          if(SentCount>0) then
  165.             'transmit' realname "(#" || acct handle || ") has been sent Letter #" || d2c(which) SentCount "times."
  166.       end
  167.    end
  168.    'transmit' ""
  169. return
  170.  
  171. IncCount:
  172.    parse arg which
  173.    SentCount=0
  174.    countFile = "Mail:Users/" || home || "/Form_Lett." || which
  175.    if(open(fp9, countFile, 'READ')) then
  176.    do
  177.       SentCount=readLN(fp9)
  178.       call close(fp9)
  179.    end
  180.  
  181.    if(open(fp9, countFile, 'WRITE')) then
  182.    do
  183.       call writeLN(fp9, SentCount+1)
  184.    end
  185.    else
  186.       'transmit' "n2 *** Can't open" countFile "for write. n2"
  187. return
  188.  
  189. ToLog:
  190.    parse arg LogString
  191.    if(log) then 'LogEntry' LogString
  192. return
  193.  
  194. LoadCfg:
  195.    if(open(fp4, cfgfile, 'READ')) then    /* SysData:FormLett.cfg */
  196.    do
  197.       do i=1 to 500
  198.          do j=1 to 3
  199.             a.i.j=strip(readLN(fp4))
  200.             if(eof(fp4)) then
  201.             do
  202.                max=i-1
  203.                return
  204.             end
  205.             if( a.i.j = '' | left(a.i.j, 1, 1)=';' ) then j=j-1  /* Skip comment-lines */
  206.          end
  207.       end
  208.    end
  209.    else
  210.       'transmit' "n2 *** Can't open" cfgfile "for read. n2"
  211. return
  212.  
  213. /*
  214.    SETMAILSUBJ {s}      This command should be performed before
  215.             EACH WRITEMAIL in order to set the SUBJECT
  216.             of the mail about to be sent.
  217.  
  218.    WRITEMAIL {s}     Write the contents of the editor temp
  219.             buffer to the user's mailbox specified
  220.             by {s}.  {s} must be a valid account
  221.             number.  RESULT will carry a "1" if
  222.             everything was sent OK, "0" otherwise.
  223. */
  224.  
  225. /*** EOF Pfiles:rexx/FormLett.rexx by Bill Beogelein 810-473-2020 ***/
  226.